package model

import (
	"broker/interface/imodel"
	messageID "broker/struct/common/message_id"
)

/**
 * @Description
 * @Author huan.wang
 * @Date 2021/4/26 10:40 下午
 **/

type SubscribeMessage struct {
	*BaseMessage
	PacketID     uint16
	TopicFilters []imodel.ITopicFilter
}

func (sm *SubscribeMessage) AddTopicFilter(filter imodel.ITopicFilter) {
	sm.TopicFilters = append(sm.TopicFilters, filter)
}

func NewSubscribeMessage() *SubscribeMessage {
	return &SubscribeMessage{
		NewMsgIDBaseMessage(messageID.Subscribe),
		0,
		make([]imodel.ITopicFilter, 0),
	}
}
